package cn.plushine.service;

import cn.plushine.mapper.BaseVisualizationMapper;
import cn.plushine.pojo.Number;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 数据可视化
 */
@Service
public class BaseVisualizationServiceImpl implements BaseVisualizationService {

    @Autowired
    BaseVisualizationMapper baseVisualizationMapper;

    // 获取数据可视化内容-数
    @Override
    public Number number() {
        // 日期
        String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        // 实例化Number类，方便返回
        Number number = new Number();
        number.setUsers(baseVisualizationMapper.users());
        number.setTasks(baseVisualizationMapper.tasks(date));
        number.setPurchases(baseVisualizationMapper.purchases(date));
        number.setSales(baseVisualizationMapper.sales(date));
        return number;
    }
}
